home *** CD-ROM | disk | FTP | other *** search
/ Champak 49 / Volume 49 - JOGO DISK .iso / Games / japanpingpong.swf / scripts / DefineSprite_498 / frame_1 / DoAction.as
Encoding:
Text File  |  2007-10-01  |  13.9 KB  |  526 lines

  1. function opening(a, b, c, d, e, f, g, h)
  2. {
  3.    eval(a).org_x = eval(a)._x;
  4.    eval(a).org_y = eval(a)._y;
  5.    eval(a).org_yxcale = eval(a)._yscale;
  6.    eval(a)._alpha = g;
  7.    eval(a)._x += c;
  8.    eval(a)._y += d;
  9.    eval(a)._xscale = eval(a)._yscale = b;
  10.    eval(a).step = f;
  11.    eval(a).memo = h;
  12.    eval(a).onEnterFrame = ZoomIn;
  13. }
  14. function ZoomIn()
  15. {
  16.    this._x += (this.org_x - this._x) / this.step;
  17.    this._y += (this.org_y - this._y) / this.step;
  18.    this._alpha += (this.memo - this._alpha) / this.step;
  19.    this._yscale += (this.org_yxcale - this._yscale) / this.step;
  20.    this._xscale = this._yscale;
  21.    this.step -= 1;
  22.    if(this._x == this.org_x and this._y == this.org_y and this._alpha == this.memo)
  23.    {
  24.       this.onEnterFrame = null;
  25.       delete this.onEnterFrame;
  26.    }
  27. }
  28. function mouseeffect()
  29. {
  30.    this._xscale += (this.scale - this._xscale) / 3;
  31.    this._yscale = this._xscale;
  32.    if(this._xscale < 101)
  33.    {
  34.       this._yscale = this._xscale = 100;
  35.       this.onEnterFrame = null;
  36.       delete this.onEnterFrame;
  37.    }
  38. }
  39. function winner(who)
  40. {
  41.    if(level != 5)
  42.    {
  43.       _root.winnerDisplay._visible = 1;
  44.       opening("_root.winnerDisplay",10,0,0,0,30);
  45.       _root.BG.Music.stop();
  46.       _root.BG.Music.setVolume(100);
  47.       if(who == "com")
  48.       {
  49.          _root.game_over.start(0,1);
  50.          _root.winnerDisplay.gotoAndStop(2);
  51.       }
  52.       else
  53.       {
  54.          _root.goal_sound.start(0,1);
  55.          _root.winnerDisplay.gotoAndStop(1);
  56.       }
  57.    }
  58.    else
  59.    {
  60.       stopAllSounds();
  61.       _parent.level = _parent.level + 1;
  62.       _parent.gotoAndStop(_parent._currentframe - 1);
  63.    }
  64. }
  65. function ShowLevel(lv)
  66. {
  67.    com_pic.gotoAndStop(lv);
  68.    if(lv == 5)
  69.    {
  70.       people_pic.gotoAndStop(2);
  71.    }
  72.    else
  73.    {
  74.       people_pic.gotoAndStop(1);
  75.    }
  76.    bg.gotoAndStop(lv);
  77. }
  78. function Check_act(who, whatup)
  79. {
  80.    if(whatup == "win")
  81.    {
  82.       if(who == "com")
  83.       {
  84.          trace("xx");
  85.          ScoreDisplay.com_score = ScoreDisplay.com_score + 1;
  86.          this.com_pic.obj.gotoAndStop(2);
  87.          this.people_pic.obj.gotoAndStop(3);
  88.       }
  89.       else
  90.       {
  91.          ScoreDisplay.people_score = ScoreDisplay.people_score + 1;
  92.          this.people_pic.obj.gotoAndStop(2);
  93.          this.com_pic.obj.gotoAndStop(3);
  94.       }
  95.    }
  96.    else if(who == "com")
  97.    {
  98.       ScoreDisplay.people_score = ScoreDisplay.people_score + 1;
  99.       this.people_pic.obj.gotoAndStop(2);
  100.       this.com_pic.obj.gotoAndStop(3);
  101.    }
  102.    else
  103.    {
  104.       ScoreDisplay.com_score = ScoreDisplay.com_score + 1;
  105.       this.com_pic.obj.gotoAndStop(2);
  106.       this.people_pic.obj.gotoAndStop(3);
  107.    }
  108.    if(ScoreDisplay.com_score >= 11 or ScoreDisplay.people_score >= 11)
  109.    {
  110.       if(Math.abs(ScoreDisplay.com_score - ScoreDisplay.people_score) >= 2)
  111.       {
  112.          if(ScoreDisplay.com_score > ScoreDisplay.people_score)
  113.          {
  114.             winner("com");
  115.          }
  116.          else
  117.          {
  118.             winner("people");
  119.          }
  120.          end = true;
  121.       }
  122.    }
  123.    delete people.onEnterFrame;
  124.    delete Com.onEnterFrame;
  125.    delete this["ball" + (dept - 1)].onEnterFrame;
  126.    clearInterval(Delay);
  127.    Delay = setInterval(Sgame,1500);
  128. }
  129. function Sgame()
  130. {
  131.    if(end != true)
  132.    {
  133.       people_pic.obj.gotoAndStop(1);
  134.       com_pic.obj.gotoAndStop(1);
  135.       Xmemo = 0;
  136.       clearInterval(Delay);
  137.       removeMovieClip("B");
  138.       removeMovieClip("Shadow");
  139.       people.onEnterFrame = Meffect;
  140.       Com.onEnterFrame = Com_effect;
  141.       Com._x = midd;
  142.       com._x = 0;
  143.       Toffset = 0;
  144.       OldY = _ymouse;
  145.       OldX = _xmouse;
  146.       offset = 0;
  147.       clearInterval(PowerCheck);
  148.       PowerCheck = setInterval(GetPower,50);
  149.       GetPower();
  150.       clearInterval(StartDelay);
  151.       Check = false;
  152.       if(Math.floor((Number(ScoreDisplay.com_score) + Number(ScoreDisplay.people_score)) / 5) % 2 == 1)
  153.       {
  154.          StartDelay = setInterval(Com_start,2000);
  155.       }
  156.       else
  157.       {
  158.          attachMovie("B_item","B",12);
  159.          B._alpha = 50;
  160.          B.onEnterFrame = Beffect;
  161.       }
  162.    }
  163. }
  164. function People_start()
  165. {
  166.    clearInterval(StartDelay);
  167.    removeMovieClip("B");
  168.    setup("ball" + dept,1,40,430,"startplayer",50,200,29,temps,"people",true);
  169.    attachMovie("B_item","B",12);
  170.    attachMovie("Shadow_item","Shadow",11);
  171.    Shadow._visible = 0;
  172. }
  173. function Com_start()
  174. {
  175.    clearInterval(StartDelay);
  176.    removeMovieClip("B");
  177.    setup("ball" + dept,1.1,0,430,"start",50,-30,23 + random(5),temps,"com",true);
  178.    attachMovie("B_item","B",12);
  179.    attachMovie("Shadow_item","Shadow",11);
  180.    Shadow._visible = 0;
  181. }
  182. function display(obj, item)
  183. {
  184.    ZPos = 100 - int(wall._x / (mR - mL) * 100);
  185.    trace(ZPos);
  186.    this.attachMovie(obj,obj,100);
  187.    Show3D(obj,item,ZPos,0,0);
  188. }
  189. function Show3D(obj, item, z, y, x)
  190. {
  191.    Salce = SalceL[z + 22] / 350;
  192.    this[obj]._x = midd - x * Salce;
  193.    this[obj]._y = 20 + SalceL[z + 22] - y * Salce;
  194.    this[obj]._xscale = this[obj]._yscale = 100 * Salce;
  195. }
  196. function Meffect()
  197. {
  198.    Tmemo = (_root._ymouse - 180) * Scale + this._width / 2 + 260;
  199.    this._x += (Tmemo - this._x) / 3;
  200.    ZPos_x = 100 - int(people._x / (mR - mL) * 100);
  201.    Tstart = ZPos_x;
  202.    if(ZPos_x > 50)
  203.    {
  204.       ZPos_x = 49;
  205.    }
  206.    Player.item._rotation = 180 - Math.atan2(Player._x - maxB._x,Player._y - 450) * 180 / 3.141592653589793;
  207.    Show3D("Player","Player",ZPos_x,10,midd - _xmouse);
  208. }
  209. function Beffect()
  210. {
  211.    Xmemo = midd - _xmouse;
  212.    if(Xmemo > 220)
  213.    {
  214.       Xmemo = 220;
  215.    }
  216.    if(Xmemo < -220)
  217.    {
  218.       Xmemo = -220;
  219.    }
  220.    Show3D("B","B",22,10,Xmemo);
  221.    if(Tstart > 22 and B._alpha == 100)
  222.    {
  223.       delete this.onEnterFrame;
  224.       Toffset = offset;
  225.       People_start();
  226.    }
  227.    if(Tstart < 5)
  228.    {
  229.       B._alpha = 100;
  230.    }
  231. }
  232. function Com_effect()
  233. {
  234.    ZPos_x = 100 - int(com._x / (mR - mL) * 100);
  235.    Show3D("Com","Com",ZPos_x,10);
  236.    if(B._x > 190 and B._x < 460)
  237.    {
  238.       this._x += (B._x - this._x) / ai[level][0];
  239.    }
  240.    this.item._rotation = 180 - Math.atan2(this._x - maxB._x,this._y - 250) * 180 / 3.141592653589793;
  241. }
  242. function setup(Name, newdept, x, y, startobj, scale, rota, str, item, id, st)
  243. {
  244.    Check = false;
  245.    dept++;
  246.    attachMovie(effect_list[item][0],Name,newdept);
  247.    this[Name].item = item;
  248.    this[Name].onEnterFrame = ball_act;
  249.    this[Name]._xscale = this[Name]._yscale = 100;
  250.    this[Name]._x = x;
  251.    this[Name]._y = y;
  252.    this[Name].lock = hittest;
  253.    this[Name].ΦºÆσ║ª = rota;
  254.    this[Name].σè¢ΘçÅ = str;
  255.    this[Name].τë⌐Σ╗╢σăΣ╜ì = eval(Name)._y;
  256.    this[Name].σƒ║µ£¼Θçìσ袠= this[Name].Θçìσ袠= effect_list[item][1];
  257.    this[Name].µïïτë⌐τ╖Ü = effect_list[item][2];
  258.    this[Name].ΦºÆσ║ªa = this[Name].ΦºÆσ║ª * 0.017453292519943295;
  259.    this[Name].xΦ╗╕ = this[Name].σè¢ΘçÅ * Math.cos(this[Name].ΦºÆσ║ªa);
  260.    this[Name].yΦ╗╕ = this[Name].σè¢ΘçÅ * Math.sin(this[Name].ΦºÆσ║ªa) * -1;
  261.    this[Name].firstrun = "no";
  262.    eval(Name)._visible = 0;
  263.    this[Name].id = id;
  264.    this[Name].Save = 0;
  265.    this[Name].st = st;
  266.    this[Name].startobj = startobj;
  267. }
  268. function ball_act()
  269. {
  270.    if(this.fist == true)
  271.    {
  272.       Xmemo += Toffset;
  273.       Xoffset = Xmemo;
  274.       ZPos = 100 - int(this._x / (mR - mL) * 100);
  275.       Show3D("B","B",ZPos,Depth - this._y,Xoffset);
  276.       ZPos = 100 - int(this._x / (mR - mL) * 100);
  277.       Show3D("Shadow","Shadow",ZPos,0,Xoffset);
  278.       if(this._x > wall._x)
  279.       {
  280.          B.swapDepths(net.getDepth() + 1);
  281.       }
  282.       else
  283.       {
  284.          B.swapDepths(net.getDepth() - 1);
  285.       }
  286.       if(this._x > com._x)
  287.       {
  288.          Com.swapDepths(net.getDepth() - 2);
  289.       }
  290.       else
  291.       {
  292.          Com.swapDepths(net.getDepth() + 2);
  293.       }
  294.    }
  295.    this.fist = true;
  296.    if(this._x < wall._x)
  297.    {
  298.       if(Check == true)
  299.       {
  300.          if(this.Save == 1)
  301.          {
  302.             com._x += (this._x - com._x) / ai[level][0];
  303.          }
  304.       }
  305.       else if(this._x - com._x > 100)
  306.       {
  307.          com._x -= 10;
  308.       }
  309.    }
  310.    else
  311.    {
  312.       com._x += (30 - com._x) / 10;
  313.    }
  314.    if(this.hitTest(wall))
  315.    {
  316.       this._x -= this.xΦ╗╕ * 2;
  317.       Toffset = -0.4;
  318.       this.xΦ╗╕ *= -0.2;
  319.       this.yΦ╗╕ *= 0.7;
  320.       if(this._x > wall._x)
  321.       {
  322.          this._x = wall._x + this._width;
  323.       }
  324.       else
  325.       {
  326.          this._x = wall._x - this._width;
  327.       }
  328.    }
  329.    if(Ox + 100 > this._x and people._x < this._x and Check == true and Player.item.hit.hitTest(B) == true and this.id == "com")
  330.    {
  331.       if(this.Save == 1)
  332.       {
  333.          _root.Chit.start(0,1);
  334.          checkpoint._x = this._x - 10;
  335.          checkpoint._y = this._y;
  336.          angle = 140 + 40 * (this._y - maxR._y) / (Player._y - maxR._y) + 10;
  337.          Power2 = (this._x - wall._x) / 250;
  338.          angle2 = (this._x - wall._x - 20) / 30 + 8;
  339.          Toffset = offset;
  340.          setup("ball" + dept,this.getDepth(),0,Depth,"checkpoint",100,angle - angle2,Number(effect_list[this.item][3]) + Power2 + Power,this.item,"people");
  341.          delete this.onEnterFrame;
  342.          removeMovieClip(this._name);
  343.       }
  344.    }
  345.    if(com._x + 100 > this._x and com._x < this._x and Check == true and Com.item.hit.hitTest(B) == true and this.id == "people")
  346.    {
  347.       if(this.Save >= 1)
  348.       {
  349.          _root.Phit.start(0,1);
  350.          checkpoint._x = this._x + 10;
  351.          checkpoint._y = this._y;
  352.          angle = 40 * (this._y - maxR._y) / (Player._y - maxR._y);
  353.          Power2 = (wall._x - this._x) / 290;
  354.          angle2 = (wall._x - this._x + 20) / 30 - 14;
  355.          KList = [1,-1];
  356.          offSetX = random(LevelList[level][0]) * LevelList[level][1] * KList[random(2)];
  357.          trace(offSetX + "  " + LevelList[level][0] + LevelList[level][1]);
  358.          if(offSetX > 0)
  359.          {
  360.             Toffset = offSetX * ((Com._x - 225) / 200);
  361.          }
  362.          else
  363.          {
  364.             Toffset = offSetX * ((Com._x - 425) * -1 / 200);
  365.          }
  366.          setup("ball" + dept,this.getDepth(),0,Depth,"checkpoint",100,angle - angle2,Number(effect_list[this.item][3]) + Power2 + random(6),this.item,"com");
  367.          delete this.onEnterFrame;
  368.          removeMovieClip(this._name);
  369.       }
  370.    }
  371.    if(this._y >= this.τë⌐Σ╗╢σăΣ╜ì)
  372.    {
  373.       this._y = this.τë⌐Σ╗╢σăΣ╜ì;
  374.       this.Θçìσ袠= this.σƒ║µ£¼Θçìσè¢;
  375.       this.σÉæΣ╕èσ袠= 0;
  376.       this.TimingReturn = false;
  377.       this.Jumping = true;
  378.    }
  379.    else
  380.    {
  381.       this.Jumping = false;
  382.       this.TimingReturn = false;
  383.       if(this._y > this.τë⌐Σ╗╢σăΣ╜ì * this.µïïτë⌐τ╖Ü)
  384.       {
  385.          this._y = this.τë⌐Σ╗╢σăΣ╜ì;
  386.          this.σÉæΣ╕èσ袠= 0;
  387.          this.TimingReturn = true;
  388.       }
  389.    }
  390.    if(this.Jumping)
  391.    {
  392.       if(this.firstrun == "no")
  393.       {
  394.          this._y = eval(this.startobj)._y - 10;
  395.          this._x = eval(this.startobj)._x;
  396.          this._visible = 1;
  397.          this.firstrun = "yes";
  398.       }
  399.       else
  400.       {
  401.          Shadow._visible = 1;
  402.          if(this.yΦ╗╕ > 0)
  403.          {
  404.             if(this.st == true)
  405.             {
  406.                this.Save--;
  407.             }
  408.             this.yΦ╗╕ *= -1;
  409.          }
  410.          if(this.id == "com" and this._x < wall._x and this.Save > 0)
  411.          {
  412.             Check_act("people","win");
  413.          }
  414.          if(this.id == "people" and this._x > wall._x and this.Save > 0)
  415.          {
  416.             Check_act("com","win");
  417.          }
  418.          if(Shadow._y > maxB._y or Shadow._y < maxT._y or Xoffset > 240 or Xoffset < -240)
  419.          {
  420.             if(this.Save <= 3)
  421.             {
  422.                if(this.Save == 0)
  423.                {
  424.                   Check_act(this.id,"lose");
  425.                   _root.Pout.start(0,1);
  426.                }
  427.                else
  428.                {
  429.                   Check_act(this.id,"win");
  430.                   _root.Pout.start(0,1);
  431.                }
  432.             }
  433.          }
  434.          else
  435.          {
  436.             _root.BG.Music.setVolume(30);
  437.             _root.SObj.S_hitTable.start(0,1);
  438.          }
  439.          this.Save = this.Save + 1;
  440.          Check = true;
  441.          if(this.Save > 3 and int(Math.abs(this.yΦ╗╕) + Math.abs(this.xΦ╗╕)) > 0 and Shadow._y < maxB._y and Shadow._y > maxT._y and Xoffset < 230 and Xoffset > -230)
  442.          {
  443.             if(this._x > wall._x)
  444.             {
  445.                Check_act("com","win");
  446.             }
  447.             else
  448.             {
  449.                Check_act("people","win");
  450.             }
  451.          }
  452.       }
  453.       this.yΦ╗╕ *= 0.99;
  454.       this.xΦ╗╕ *= 0.99;
  455.       this.σÉæΣ╕èσ袠= this.yΦ╗╕;
  456.    }
  457.    if(!this.Jumping)
  458.    {
  459.       if(this._y < this.τë⌐Σ╗╢σăΣ╜ì)
  460.       {
  461.          this.σÉæΣ╕èσ袠+= this.Θçìσ袠* speed_list[level];
  462.          this.Θçìσ袠*= 1.0013;
  463.       }
  464.    }
  465.    if(!this.TimingReturn)
  466.    {
  467.       this.Jumping = false;
  468.    }
  469.    this.xΦ╗╕ *= 0.998;
  470.    this.yΦ╗╕ *= 0.998;
  471.    this._x += this.xΦ╗╕ * speed_list[level];
  472.    this._y += this.σÉæΣ╕èσ袠* speed_list[level];
  473. }
  474. function GetPower()
  475. {
  476.    offset = (OldX - _xmouse) / 5;
  477.    Power = (OldY - _ymouse) / 10;
  478.    OldX = _xmouse;
  479.    OldY = _ymouse;
  480.    Ox = people._x;
  481. }
  482. level = _root.level;
  483. LevelList = [[10,1],[12,1],[5,2],[6,2],[4,3],[6,2]];
  484. end = false;
  485. Depth = 420;
  486. SalceL = [];
  487. STemp = 500;
  488. i = 1;
  489. while(i < 130)
  490. {
  491.    SalceL[i] = STemp - 70;
  492.    STemp *= 0.993111;
  493.    i++;
  494. }
  495. ScoreDisplay.LevelDisplay = level;
  496. opening("people_pic",10,0,0,0,10);
  497. opening("com_pic",10,0,0,0,10);
  498. opening("ScoreDisplay",100,0,-100,0,20);
  499. opening("StartBtn",10,0,0,0,15);
  500. mR = maxR._x;
  501. mL = maxL._x;
  502. mT = maxT._y;
  503. mB = maxB._y;
  504. Yscale = mB - mT;
  505. Xscale = mR - mL;
  506. Scale = 3.4583333333333335;
  507. midd = 325;
  508. Player.swapDepths(999);
  509. display("net","wall");
  510. ShowLevel(level);
  511. dept = 1;
  512. temps = 0;
  513. speed_list = [1,1.01,1.01,1.02,1.02,1.03];
  514. ai = [[7,12],[7,12],[7,11],[7,11],[6,11],[5,10]];
  515. effect_list = [["football",1.2,0.99,23,37]];
  516. _root.winnerDisplay.swapDepths(1000);
  517. _root.winnerDisplay._visible = 0;
  518. stop();
  519. StartBtn.swapDepths(99999);
  520. StartBtn.onPress = function()
  521. {
  522.    clearInterval(Delay);
  523.    Delay = setInterval(Sgame,1000);
  524.    this._visible = 0;
  525. };
  526.